#include <QtGui>

#include "invader.h"

Invader::Invader (const QString &invaderGif, InvaderType type, QWidget *parent)
  : QLabel (parent)
{
  _movie = new QMovie (this);
  _movie->setCacheMode (QMovie::CacheAll);
  _movie->setFileName (invaderGif);
  _movie->jumpToFrame (0);

  setMovie (_movie);

  _type = type;
}

int Invader::shootPercent = 3;

void Invader::advanceFrame ()
{
  _movie->jumpToNextFrame ();

  if (isVisible () && qrand () % 100 < shootPercent)
    emit shoots ();
}
